package com.example.service.impl;

import com.example.details.ProviderTestDTO;
import com.example.service.IProviderService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;


/**
 * @author ：songxusheng
 * @date ：Created in 2022/4/7 14:59
 * @description：接口实现类
 * @version: $
 */
@Service
public class ProviderServiceImpl implements IProviderService {
    @Override
    public List<ProviderTestDTO> queryList() {
        List<ProviderTestDTO> list=new ArrayList<>();
        list.add(new ProviderTestDTO(1,"张三",20));
        list.add(new ProviderTestDTO(2,"李四",25));
        list.add(new ProviderTestDTO(3,"王五",22));
        return list;
    }

    @Override
    public void uploadFile(byte[] bytefile, String name, String originalFilename, String contentType) {
        System.out.println(bytefile.length);
        InputStream inputStream = new ByteArrayInputStream(bytefile);
        try {
            MultipartFile file = new MockMultipartFile(name, originalFilename, contentType, inputStream);
            System.out.println(file.getSize());
            System.out.println(file.getOriginalFilename());
            System.out.println(file.getName());
            System.out.println(file.getContentType());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


}
